//extend jQuery
$.extend({
 getUrlVars: function(){
  var vars = {}, hash;
  var hashes = location.search.slice(location.search.indexOf('?') + 1).split('&');
  for(var i = 0; i < hashes.length; i++)
  {
    hash = hashes[i].split('=');
    vars[hash[0]] = hash[1];
  }
  return vars;
},
getUrlVar: function(name){
  return $.getUrlVars()[name];
}
});

/* ON LOAD */
$(function(){
  //get token from page
  var token = $.getUrlVar('token');
  if (typeof token != 'undefined') {
    chrome.extension.sendMessage({contentscript_token: token});
  }
  //reset token 
  var logout = $.getUrlVar('logout');
  if (typeof logout != 'undefined') {
    chrome.extension.sendMessage({contentscript_token: 'logout'});
  }

  
});